package com.itfetter.listen;

import com.itfetter.service.OrderService;
import lombok.RequiredArgsConstructor;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.annotation.SelectorType;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import static org.apache.rocketmq.spring.annotation.MessageModel.BROADCASTING;
import static org.apache.rocketmq.spring.annotation.MessageModel.CLUSTERING;

@Component
@RequiredArgsConstructor
@RocketMQMessageListener(consumerGroup = "rocketmq-consumer-group", topic = "hello-rocketmq",
        messageModel = CLUSTERING,
        selectorType = SelectorType.SQL92,
        selectorExpression = "name='xiaohei' and age>16")
public class RocketMQListen implements RocketMQListener<String> {
    private final OrderService orderService;

    @Override
    public void onMessage(String s) {
        System.out.println("收到消息消息是：" + s);
        orderService.pay(s);
    }
}
